//编辑
Ext.define('Admin.view.settle.TradeResultDetailListDetail', {
	        extend : 'Admin.form.DetailForm',
	        alias : 'widget.tradeResultDetailListDetail',

	        defaults : {
		        labelWidth : 120
	        },

	        layout : {
		        type : 'column'
	        },
	        width : 900,
	        items : [{
	        	columnWidth: 0.36,
	        	items:[{
	        		id:'peakEnergy',
		        	xtype : 'xnumberfield',
	                fieldLabel : '峰段：电量(兆瓦时)',
	                labelWidth:120,
	                bind : {
		                value : '{record.peakEnergy}'
	                },
	                listeners:{
	                	blur:function() {
	                		//失去焦点，计算电费和总的电量
	                		//计算电费
	                		var me = this,peakEnergy = me.getValue();
	                		var peakFee = Ext.getCmp('peakFee');
	                		var peakPrice = Ext.getCmp('peakPrice');
	                		peakFee.setValue(peakPrice.getValue()*peakEnergy);
	                		//计算总电量
	                		var energy = Ext.getCmp('energy');
	                		var flatEnergy = Ext.getCmp('flatEnergy');
	                		var valleyEnergy = Ext.getCmp('valleyEnergy');
	                		energy.setValue(peakEnergy+flatEnergy.getValue()+valleyEnergy.getValue());
	                		//计算总电费
	                		var price = Ext.getCmp('price');
	                		var fee = Ext.getCmp('fee');
	                		fee.setValue(price.getValue()*energy.getValue());
	                	}
	                }},{
	                	id:'flatEnergy',
			        	xtype : 'xnumberfield',
		                fieldLabel : '平段：电量(兆瓦时)',
		                labelWidth:120,
		                bind : {
			                value : '{record.flatEnergy}'
		                },
		                listeners:{
		                	blur:function(){
		                		var flatEnergy = this ;
		                		//计算电费
		                		var flatPrice = Ext.getCmp('flatPrice');
		                		var flatFee = Ext.getCmp('flatFee');
		                		flatFee.setValue(flatEnergy.getValue()*flatPrice.getValue());
		                		//计算总电量
		                		var peakEnergy = Ext.getCmp('peakEnergy');
		                		var valleyEnergy = Ext.getCmp('valleyEnergy');
		                		var energy = Ext.getCmp('energy');
		                		energy.setValue(peakEnergy.getValue()+flatEnergy.getValue()+valleyEnergy.getValue());
		                		//计算总电费
		                		 var fee = Ext.getCmp('fee');
		                		 var price = Ext.getCmp('price');
		                		 fee.setValue(price.getValue()*energy.getValue());
		                	}
		                }},{
		                	id:'valleyEnergy',
				        	xtype : 'xnumberfield',
			                fieldLabel : '谷段：电量(兆瓦时)',
			                labelWidth:120,
			                bind : {
				                value : '{record.valleyEnergy}'
			                },
			                listeners:{
			                	blur:function(){
			                		//计算电费
			                		var valleyEnergy = this;
			                		var valleyPrice = Ext.getCmp('valleyPrice');
			                		var valleyFee = Ext.getCmp('valleyFee');
			                		valleyFee.setValue(valleyPrice.getValue()*valleyEnergy.getValue());
			                		//计算总电量
			                		var peakEnergy = Ext.getCmp('peakEnergy');
			                		var flatEnergy = Ext.getCmp('flatEnergy');
			                		var energy = Ext.getCmp('energy');
			                		energy.setValue(peakEnergy.getValue()+flatEnergy.getValue()+valleyEnergy.getValue());
			                		//计算总电费
			                		 var fee = Ext.getCmp('fee');
			                		 var price = Ext.getCmp('price');
			                		 fee.setValue(price.getValue()*energy.getValue());
			                	}
			                }},{
			                	id:'energy',
					        	xtype : 'xnumberfield',
				                fieldLabel : '总计：电量(兆瓦时)',
				                labelWidth:120,
				                bind : {
					                value : '{record.energy}'
				                },
				                listeners:{
				                	blur:function(){
				                		var energy = Ext.getCmp('energy');
				                		var peakEnergy = Ext.getCmp('peakEnergy');
				                		var flatEnergy = Ext.getCmp('flatEnergy');
				                		var valleyEnergy = Ext.getCmp('valleyEnergy');
				                		var totalEnergy = peakEnergy.getValue()+flatEnergy.getValue()+valleyEnergy.getValue()
				                		if(totalEnergy!=0&&totalEnergy != null && totalEnergy!='undefined'
				                			&&totalEnergy!=energy.getValue()){
				                			Ext.Msg.alert('提示','总电量和峰平谷之和不想等');
				                		}else{
				                			//计算总电费
					                		 var fee = Ext.getCmp('fee');
					                		 var price = Ext.getCmp('price');
					                		 fee.setValue(price.getValue()*energy.getValue());
				                		}
				                	}
				                }}]
	        },{
	        	columnWidth: 0.32,  
	        	items:[{
	        		id:'peakPrice',
    	        	xtype : 'xnumberfield',
                    fieldLabel : '电价(元/兆瓦时)',
                    bind : {
    	                value : '{record.peakPrice}'
                    },
                    listeners:{
                    	blur:function(){
                    		//计算电费
                    		var peakPrice = this;
                    		var peakEnergy = Ext.getCmp('peakEnergy');
                    		var peakFee = Ext.getCmp('peakFee');
                    		peakFee.setValue(peakPrice.getValue()*peakEnergy.getValue());
                    		//计算总电费
                    	}
                    }},{
                    	id:'flatPrice',
        	        	xtype : 'xnumberfield',
                        fieldLabel : '电价(元/兆瓦时)',
                        bind : {
        	                value : '{record.flatPrice}'
                        },
                        listeners:{
                        	blur:function(){
                        		//计算电费
                        		var flatPrice = this;
                        		var flatEnergy = Ext.getCmp('flatEnergy');
                        		var flatFee = Ext.getCmp('flatFee');
                        		flatFee.setValue(flatPrice.getValue()*flatEnergy.getValue());
                        	}
                        }},{
                        	id:'valleyPrice',
            	        	xtype : 'xnumberfield',
                            fieldLabel : '电价(元/兆瓦时)',
                            bind : {
            	                value : '{record.valleyPrice}'
                            },
                            listeners:{
                            	blur:function(){
                            		//计算电费
                            		var valleyPrice = this;
                            		var valleyEnergy = Ext.getCmp('valleyEnergy');
                            		var valleyFee = Ext.getCmp('valleyFee');
                            		valleyFee.setValue(valleyPrice.getValue()*valleyEnergy.getValue());
                            	}
                            }},{
                            	id:'price',
                	        	xtype : 'xnumberfield',
                                fieldLabel : '电价(元/兆瓦时)',
                                bind : {
                	                value : '{record.price}'
                                },
                                listeners:{
                                	blur:function(){
                                		//计算电费
                                		var price = this;
                                		var energy = Ext.getCmp('energy');
                                		var fee = Ext.getCmp('fee');
                                		fee.setValue(price.getValue()*energy.getValue());
                                	}
                                }}]
	        },{
	        	columnWidth: 0.32,  
	        	items:[{
	        		id:'peakFee',
    	        	xtype : 'xnumberfield',
                    fieldLabel : '电费(元)',
                    readOnly:true,
                    bind : {
    	                value : '{record.peakFee}'
                    }},{
                    	id:'flatFee',
        	        	xtype : 'xnumberfield',
                        fieldLabel : '电费(元)',
                        readOnly:true,
                        bind : {
        	                value : '{record.flatFee}'
                        }},{
                        	id:'valleyFee',
            	        	xtype : 'xnumberfield',
                            fieldLabel : '电费(元)',
                            readOnly:true,
                            columnWidth: 0.32, 
                            bind : {
            	                value : '{record.valleyFee}'
                            }},{
                            	id:'fee',
                	        	xtype : 'xnumberfield',
                                fieldLabel : '电费(元)',
                                readOnly:true,
                                columnWidth: 0.32, 
                                bind : {
                	                value : '{record.fee}'
                                }}]   	       
	        	       
	        }]
        });
